<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
    <title>Coverage for I:\CourseRegistration\registrar\views.py: 16%</title>
    <link rel="stylesheet" href="style.css" type="text/css">
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="jquery.hotkeys.js"></script>
    <script type="text/javascript" src="jquery.isonscreen.js"></script>
    <script type="text/javascript" src="coverage_html.js"></script>
    <script type="text/javascript">
        jQuery(document).ready(coverage.pyfile_ready);
    </script>
</head>
<body class="pyfile">
<div id="header">
    <div class="content">
        <h1>Coverage for <b>I:\CourseRegistration\registrar\views.py</b> :
            <span class="pc_cov">16%</span>
        </h1>
        <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
        <h2 class="stats">
            228 statements &nbsp;
            <span class="run shortkey_r button_toggle_run">36 run</span>
            <span class="mis show_mis shortkey_m button_toggle_mis">192 missing</span>
            <span class="exc show_exc shortkey_x button_toggle_exc">0 excluded</span>
        </h2>
    </div>
</div>
<div class="help_panel">
    <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
    <p class="legend">Hot-keys on this page</p>
    <div>
    <p class="keyhelp">
        <span class="key">r</span>
        <span class="key">m</span>
        <span class="key">x</span>
        <span class="key">p</span> &nbsp; toggle line displays
    </p>
    <p class="keyhelp">
        <span class="key">j</span>
        <span class="key">k</span> &nbsp; next/prev highlighted chunk
    </p>
    <p class="keyhelp">
        <span class="key">0</span> &nbsp; (zero) top of page
    </p>
    <p class="keyhelp">
        <span class="key">1</span> &nbsp; (one) first highlighted chunk
    </p>
    </div>
</div>
<div id="source">
    <p id="t1" class="run"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="key">from</span> <span class="op">.</span> <span class="key">import</span> <span class="nam">rgs</span>&nbsp;</span><span class="r"></span></p>
    <p id="t2" class="run"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="key">from</span> <span class="nam">flask</span> <span class="key">import</span> <span class="nam">render_template</span><span class="op">,</span> <span class="nam">redirect</span><span class="op">,</span> <span class="nam">request</span><span class="op">,</span> <span class="nam">url_for</span><span class="op">,</span> <span class="nam">flash</span>&nbsp;</span><span class="r"></span></p>
    <p id="t3" class="run"><span class="n"><a href="#t3">3</a></span><span class="t"><span class="key">from</span> <span class="nam">flask_login</span> <span class="key">import</span> <span class="nam">login_required</span><span class="op">,</span> <span class="nam">current_user</span>&nbsp;</span><span class="r"></span></p>
    <p id="t4" class="run"><span class="n"><a href="#t4">4</a></span><span class="t"><span class="key">from</span> <span class="nam">models</span> <span class="key">import</span> <span class="nam">Student</span><span class="op">,</span> <span class="nam">Course</span><span class="op">,</span> <span class="nam">Takes</span><span class="op">,</span> <span class="nam">Inputbox</span><span class="op">,</span> <span class="nam">Prerequisite</span><span class="op">,</span> <span class="nam">Bill</span><span class="op">,</span> <span class="nam">Professor</span><span class="op">,</span> <span class="nam">Section</span>&nbsp;</span><span class="r"></span></p>
    <p id="t5" class="run"><span class="n"><a href="#t5">5</a></span><span class="t"><span class="key">import</span> <span class="nam">datetime</span>&nbsp;</span><span class="r"></span></p>
    <p id="t6" class="run"><span class="n"><a href="#t6">6</a></span><span class="t"><span class="key">from</span> <span class="nam">app</span> <span class="key">import</span> <span class="nam">db</span>&nbsp;</span><span class="r"></span></p>
    <p id="t7" class="run"><span class="n"><a href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">models</span> <span class="key">import</span> <span class="nam">Teaches</span>&nbsp;</span><span class="r"></span></p>
    <p id="t8" class="run"><span class="n"><a href="#t8">8</a></span><span class="t"><span class="key">from</span> <span class="nam">sqlalchemy</span> <span class="key">import</span> <span class="nam">func</span>&nbsp;</span><span class="r"></span></p>
    <p id="t9" class="run"><span class="n"><a href="#t9">9</a></span><span class="t"><span class="key">from</span> <span class="nam">registrar</span><span class="op">.</span><span class="nam">forms</span> <span class="key">import</span> <span class="nam">NewStudentForm</span><span class="op">,</span> <span class="nam">StudentForm</span><span class="op">,</span> <span class="nam">UpdateStudentForm</span><span class="op">,</span> <span class="nam">NewProfessorForm</span><span class="op">,</span> <span class="nam">ProfessorForm</span><span class="op">,</span> <span class="nam">UpdateProfessorForm</span>&nbsp;</span><span class="r"></span></p>
    <p id="t10" class="run"><span class="n"><a href="#t10">10</a></span><span class="t"><span class="key">from</span> <span class="nam">datetime</span> <span class="key">import</span> <span class="nam">date</span>&nbsp;</span><span class="r"></span></p>
    <p id="t11" class="pln"><span class="n"><a href="#t11">11</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t12" class="pln"><span class="n"><a href="#t12">12</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t13" class="run"><span class="n"><a href="#t13">13</a></span><span class="t"><span class="op">@</span><span class="nam">rgs</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/registrar-home'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t14" class="run"><span class="n"><a href="#t14">14</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t15" class="pln"><span class="n"><a href="#t15">15</a></span><span class="t"><span class="key">def</span> <span class="nam">registrar_home</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t16" class="pln"><span class="n"><a href="#t16">16</a></span><span class="t">    <span class="com"># &#36825;&#26159;&#31649;&#29702;&#21592;&#30340;&#20027;&#39029;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t17" class="pln"><span class="n"><a href="#t17">17</a></span><span class="t">    <span class="com"># &#26412;&#39029;&#38754;&#21069;&#31471;&#25552;&#20379;&#38142;&#25509;&#21040;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t18" class="pln"><span class="n"><a href="#t18">18</a></span><span class="t">    <span class="com"># 1. rgs.registrar_maintain_student_information</span>&nbsp;</span><span class="r"></span></p>
    <p id="t19" class="pln"><span class="n"><a href="#t19">19</a></span><span class="t">    <span class="com"># 2. rgs.registrar_maintain_professor_information</span>&nbsp;</span><span class="r"></span></p>
    <p id="t20" class="pln"><span class="n"><a href="#t20">20</a></span><span class="t">    <span class="com"># 3. rgs.registrar_list_course_to_cancel</span>&nbsp;</span><span class="r"></span></p>
    <p id="t21" class="pln"><span class="n"><a href="#t21">21</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#27809;&#26377;&#25968;&#25454;&#24211;&#22788;&#29702;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t22" class="pln"><span class="n"><a href="#t22">22</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t23" class="mis show_mis"><span class="n"><a href="#t23">23</a></span><span class="t">    <span class="nam">today</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">today</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t24" class="mis show_mis"><span class="n"><a href="#t24">24</a></span><span class="t">    <span class="nam">name</span> <span class="op">=</span> <span class="nam">current_user</span><span class="op">.</span><span class="nam">get_name</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t25" class="mis show_mis"><span class="n"><a href="#t25">25</a></span><span class="t">    <span class="nam">greeting</span> <span class="op">=</span> <span class="nam">name</span> <span class="op">+</span> <span class="str">"&#31649;&#29702;&#21592;&#65292;&#24744;&#22909;&#65281;&#29616;&#22312;&#26159;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">today</span><span class="op">.</span><span class="nam">year</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#24180;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">today</span><span class="op">.</span><span class="nam">month</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#26376;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">today</span><span class="op">.</span><span class="nam">day</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#26085;&#65292;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t26" class="pln"><span class="n"><a href="#t26">26</a></span><span class="t">        <span class="nam">today</span><span class="op">.</span><span class="nam">hour</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#26102;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t27" class="pln"><span class="n"><a href="#t27">27</a></span><span class="t">        <span class="nam">today</span><span class="op">.</span><span class="nam">minute</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#20998;"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t28" class="mis show_mis"><span class="n"><a href="#t28">28</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_home.html'</span><span class="op">,</span> <span class="nam">greeting</span><span class="op">=</span><span class="nam">greeting</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t29" class="pln"><span class="n"><a href="#t29">29</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t30" class="pln"><span class="n"><a href="#t30">30</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t31" class="run"><span class="n"><a href="#t31">31</a></span><span class="t"><span class="op">@</span><span class="nam">rgs</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/registrar-maintain-student-information'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t32" class="run"><span class="n"><a href="#t32">32</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t33" class="pln"><span class="n"><a href="#t33">33</a></span><span class="t"><span class="key">def</span> <span class="nam">registrar_maintain_student_information</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t34" class="pln"><span class="n"><a href="#t34">34</a></span><span class="t">    <span class="com"># &#26412;&#39029;&#38754;&#21069;&#31471;&#25552;&#20379;&#25552;&#20379;&#38142;&#25509;&#21040;&#28155;&#21152;&#23398;&#29983;&#21644;&#21024;&#38500;&#23398;&#29983;&#20197;&#21450;update&#23398;&#29983;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t35" class="pln"><span class="n"><a href="#t35">35</a></span><span class="t">    <span class="com"># 1. rgs.registrar_add_student</span>&nbsp;</span><span class="r"></span></p>
    <p id="t36" class="pln"><span class="n"><a href="#t36">36</a></span><span class="t">    <span class="com"># 2. rgs.registrar_delete_student</span>&nbsp;</span><span class="r"></span></p>
    <p id="t37" class="pln"><span class="n"><a href="#t37">37</a></span><span class="t">    <span class="com"># 3. rgs.registrar_update_student</span>&nbsp;</span><span class="r"></span></p>
    <p id="t38" class="pln"><span class="n"><a href="#t38">38</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#26080;&#25968;&#25454;&#24211;&#22788;&#29702;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t39" class="mis show_mis"><span class="n"><a href="#t39">39</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_maintain_student_information.html'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t40" class="pln"><span class="n"><a href="#t40">40</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t41" class="pln"><span class="n"><a href="#t41">41</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t42" class="run"><span class="n"><a href="#t42">42</a></span><span class="t"><span class="op">@</span><span class="nam">rgs</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/registrar-add-student'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t43" class="run"><span class="n"><a href="#t43">43</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t44" class="pln"><span class="n"><a href="#t44">44</a></span><span class="t"><span class="key">def</span> <span class="nam">registrar_add_student</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t45" class="pln"><span class="n"><a href="#t45">45</a></span><span class="t">    <span class="com"># &#26412;&#39029;&#38754;&#23454;&#29616;&#28155;&#21152;&#23398;&#29983;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t46" class="pln"><span class="n"><a href="#t46">46</a></span><span class="t">    <span class="com"># &#38656;&#35201;&#31649;&#29702;&#21592;&#22635;&#20889;&#34920;&#21333;&#65306;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t47" class="mis show_mis"><span class="n"><a href="#t47">47</a></span><span class="t">    <span class="nam">form</span> <span class="op">=</span> <span class="nam">NewStudentForm</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t48" class="mis show_mis"><span class="n"><a href="#t48">48</a></span><span class="t">    <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">validate_on_submit</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t49" class="mis show_mis"><span class="n"><a href="#t49">49</a></span><span class="t">        <span class="nam">student</span> <span class="op">=</span> <span class="nam">Student</span><span class="op">(</span><span class="nam">student_id</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">student_id</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t50" class="pln"><span class="n"><a href="#t50">50</a></span><span class="t">                          <span class="nam">password</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">password</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t51" class="pln"><span class="n"><a href="#t51">51</a></span><span class="t">                          <span class="nam">student_name</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">student_name</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t52" class="pln"><span class="n"><a href="#t52">52</a></span><span class="t">                          <span class="nam">date_of_birth</span><span class="op">=</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">strptime</span><span class="op">(</span><span class="nam">form</span><span class="op">.</span><span class="nam">date_of_birth</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span> <span class="str">'%Y-%m-%d'</span><span class="op">)</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t53" class="pln"><span class="n"><a href="#t53">53</a></span><span class="t">                          <span class="nam">social_security_number</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">social_security_number</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t54" class="pln"><span class="n"><a href="#t54">54</a></span><span class="t">                          <span class="nam">status</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">status</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t55" class="pln"><span class="n"><a href="#t55">55</a></span><span class="t">                          <span class="nam">graduation_date</span><span class="op">=</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">strptime</span><span class="op">(</span><span class="nam">form</span><span class="op">.</span><span class="nam">graduation_date</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span> <span class="str">'%Y-%m-%d'</span><span class="op">)</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t56" class="pln"><span class="n"><a href="#t56">56</a></span><span class="t">                          <span class="nam">department</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">department</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t57" class="pln"><span class="n"><a href="#t57">57</a></span><span class="t">                          <span class="nam">balance</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">balance</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t58" class="mis show_mis"><span class="n"><a href="#t58">58</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">add</span><span class="op">(</span><span class="nam">student</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t59" class="mis show_mis"><span class="n"><a href="#t59">59</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t60" class="mis show_mis"><span class="n"><a href="#t60">60</a></span><span class="t">        <span class="nam">flash</span><span class="op">(</span><span class="str">'&#25104;&#21151;&#28155;&#21152;&#23398;&#29983;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t61" class="mis show_mis"><span class="n"><a href="#t61">61</a></span><span class="t">        <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'rgs.registrar_maintain_student_information'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t62" class="mis show_mis"><span class="n"><a href="#t62">62</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_add_student.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t63" class="pln"><span class="n"><a href="#t63">63</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t64" class="pln"><span class="n"><a href="#t64">64</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t65" class="run"><span class="n"><a href="#t65">65</a></span><span class="t"><span class="op">@</span><span class="nam">rgs</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/registrar-delete-student'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t66" class="run"><span class="n"><a href="#t66">66</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t67" class="pln"><span class="n"><a href="#t67">67</a></span><span class="t"><span class="key">def</span> <span class="nam">registrar_delete_student</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t68" class="pln"><span class="n"><a href="#t68">68</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#23454;&#29616;&#21024;&#38500;&#23398;&#29983;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t69" class="pln"><span class="n"><a href="#t69">69</a></span><span class="t">    <span class="com"># &#38656;&#35201;&#31649;&#29702;&#21592;&#22635;&#20889;&#34920;&#21333;&#65306;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t70" class="mis show_mis"><span class="n"><a href="#t70">70</a></span><span class="t">    <span class="nam">form</span> <span class="op">=</span> <span class="nam">StudentForm</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t71" class="mis show_mis"><span class="n"><a href="#t71">71</a></span><span class="t">    <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">validate_on_submit</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t72" class="mis show_mis"><span class="n"><a href="#t72">72</a></span><span class="t">        <span class="nam">student</span> <span class="op">=</span> <span class="nam">Student</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Student</span><span class="op">.</span><span class="nam">student_id</span> <span class="op">==</span> <span class="nam">form</span><span class="op">.</span><span class="nam">student_id</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t73" class="mis show_mis"><span class="n"><a href="#t73">73</a></span><span class="t">        <span class="key">if</span> <span class="nam">student</span> <span class="key">is</span> <span class="key">None</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t74" class="mis show_mis"><span class="n"><a href="#t74">74</a></span><span class="t">            <span class="nam">flash</span><span class="op">(</span><span class="str">'&#31995;&#32479;&#19981;&#23384;&#22312;&#35813;&#23398;&#29983;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t75" class="mis show_mis"><span class="n"><a href="#t75">75</a></span><span class="t">            <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_delete_student.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t76" class="pln"><span class="n"><a href="#t76">76</a></span><span class="t">        <span class="com"># &#21024;&#38500;&#35813;&#23398;&#29983;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t77" class="mis show_mis"><span class="n"><a href="#t77">77</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">delete</span><span class="op">(</span><span class="nam">student</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t78" class="mis show_mis"><span class="n"><a href="#t78">78</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t79" class="pln"><span class="n"><a href="#t79">79</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t80" class="pln"><span class="n"><a href="#t80">80</a></span><span class="t">        <span class="com"># &#36825;&#37324;&#21487;&#33021;&#35201;&#32771;&#34385;&#20854;&#20182;&#34920;&#20013;&#35813;&#23398;&#29983;&#30340;&#20449;&#24687;&#20250;&#19981;&#20250;&#33258;&#21160;&#26681;&#25454;key&#26356;&#26032;&#65292;&#22914;&#26524;&#20250;&#65292;&#21017;&#19981;&#38656;&#35201;&#39069;&#22806;&#30340;&#25805;&#20316;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t81" class="pln"><span class="n"><a href="#t81">81</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t82" class="mis show_mis"><span class="n"><a href="#t82">82</a></span><span class="t">        <span class="nam">flash</span><span class="op">(</span><span class="str">'&#25104;&#21151;&#21024;&#38500;&#35813;&#23398;&#29983;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t83" class="mis show_mis"><span class="n"><a href="#t83">83</a></span><span class="t">        <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'rgs.registrar_maintain_student_information'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t84" class="mis show_mis"><span class="n"><a href="#t84">84</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_delete_student.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t85" class="pln"><span class="n"><a href="#t85">85</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t86" class="pln"><span class="n"><a href="#t86">86</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t87" class="run"><span class="n"><a href="#t87">87</a></span><span class="t"><span class="op">@</span><span class="nam">rgs</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/registrar-update-student'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t88" class="run"><span class="n"><a href="#t88">88</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t89" class="pln"><span class="n"><a href="#t89">89</a></span><span class="t"><span class="key">def</span> <span class="nam">registrar_update_student</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t90" class="pln"><span class="n"><a href="#t90">90</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#23454;&#29616;&#26356;&#26032;&#23398;&#29983;&#20449;&#24687;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t91" class="pln"><span class="n"><a href="#t91">91</a></span><span class="t">    <span class="com"># &#38656;&#35201;&#31649;&#29702;&#21592;&#22635;&#20889;&#34920;&#21333;&#65306;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t92" class="pln"><span class="n"><a href="#t92">92</a></span><span class="t">    <span class="com"># &#36825;&#37324;&#30340;&#34920;&#21333;&#21482;&#26377;id&#26159;&#24517;&#22635;&#39033;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t93" class="mis show_mis"><span class="n"><a href="#t93">93</a></span><span class="t">    <span class="nam">form</span> <span class="op">=</span> <span class="nam">UpdateStudentForm</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t94" class="mis show_mis"><span class="n"><a href="#t94">94</a></span><span class="t">    <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">validate_on_submit</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t95" class="mis show_mis"><span class="n"><a href="#t95">95</a></span><span class="t">        <span class="nam">student</span> <span class="op">=</span> <span class="nam">Student</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Student</span><span class="op">.</span><span class="nam">student_id</span> <span class="op">==</span> <span class="nam">form</span><span class="op">.</span><span class="nam">student_id</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t96" class="mis show_mis"><span class="n"><a href="#t96">96</a></span><span class="t">        <span class="key">if</span> <span class="nam">student</span> <span class="key">is</span> <span class="key">None</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t97" class="mis show_mis"><span class="n"><a href="#t97">97</a></span><span class="t">            <span class="nam">flash</span><span class="op">(</span><span class="str">'&#31995;&#32479;&#19981;&#23384;&#22312;&#35813;&#23398;&#29983;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t98" class="mis show_mis"><span class="n"><a href="#t98">98</a></span><span class="t">            <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_update_student.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t99" class="pln"><span class="n"><a href="#t99">99</a></span><span class="t">        <span class="com"># &#36825;&#37324;&#29992;if-else&#26292;&#21147;&#25628;&#32034;&#65292;&#21487;&#33021;&#20250;&#26377;&#19968;&#20123;&#38382;&#39064;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t100" class="mis show_mis"><span class="n"><a href="#t100">100</a></span><span class="t">        <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">password</span><span class="op">.</span><span class="nam">data</span> <span class="op">!=</span> <span class="str">""</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t101" class="mis show_mis"><span class="n"><a href="#t101">101</a></span><span class="t">            <span class="nam">student</span><span class="op">.</span><span class="nam">password</span> <span class="op">=</span> <span class="nam">form</span><span class="op">.</span><span class="nam">password</span><span class="op">.</span><span class="nam">data</span>&nbsp;</span><span class="r"></span></p>
    <p id="t102" class="mis show_mis"><span class="n"><a href="#t102">102</a></span><span class="t">        <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">student_name</span><span class="op">.</span><span class="nam">data</span> <span class="op">!=</span> <span class="str">""</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t103" class="mis show_mis"><span class="n"><a href="#t103">103</a></span><span class="t">            <span class="nam">student</span><span class="op">.</span><span class="nam">student_name</span> <span class="op">=</span> <span class="nam">form</span><span class="op">.</span><span class="nam">student_name</span><span class="op">.</span><span class="nam">data</span>&nbsp;</span><span class="r"></span></p>
    <p id="t104" class="mis show_mis"><span class="n"><a href="#t104">104</a></span><span class="t">        <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">date_of_birth</span><span class="op">.</span><span class="nam">data</span> <span class="op">!=</span> <span class="str">""</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t105" class="mis show_mis"><span class="n"><a href="#t105">105</a></span><span class="t">            <span class="nam">student</span><span class="op">.</span><span class="nam">date_of_birth</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">strptime</span><span class="op">(</span><span class="nam">form</span><span class="op">.</span><span class="nam">date_of_birth</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span> <span class="str">'%Y-%m-%d'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t106" class="mis show_mis"><span class="n"><a href="#t106">106</a></span><span class="t">        <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">social_security_number</span><span class="op">.</span><span class="nam">data</span> <span class="op">!=</span> <span class="str">""</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t107" class="mis show_mis"><span class="n"><a href="#t107">107</a></span><span class="t">            <span class="nam">student</span><span class="op">.</span><span class="nam">social_security_number</span> <span class="op">=</span> <span class="nam">form</span><span class="op">.</span><span class="nam">social_security_number</span><span class="op">.</span><span class="nam">data</span>&nbsp;</span><span class="r"></span></p>
    <p id="t108" class="mis show_mis"><span class="n"><a href="#t108">108</a></span><span class="t">        <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">status</span><span class="op">.</span><span class="nam">data</span> <span class="op">!=</span> <span class="str">""</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t109" class="mis show_mis"><span class="n"><a href="#t109">109</a></span><span class="t">            <span class="nam">student</span><span class="op">.</span><span class="nam">status</span> <span class="op">=</span> <span class="nam">form</span><span class="op">.</span><span class="nam">status</span><span class="op">.</span><span class="nam">data</span>&nbsp;</span><span class="r"></span></p>
    <p id="t110" class="mis show_mis"><span class="n"><a href="#t110">110</a></span><span class="t">        <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">graduation_date</span><span class="op">.</span><span class="nam">data</span> <span class="op">!=</span> <span class="str">""</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t111" class="mis show_mis"><span class="n"><a href="#t111">111</a></span><span class="t">            <span class="nam">student</span><span class="op">.</span><span class="nam">graduation_date</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">strptime</span><span class="op">(</span><span class="nam">form</span><span class="op">.</span><span class="nam">graduation_date</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span> <span class="str">'%Y-%m-%d'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t112" class="mis show_mis"><span class="n"><a href="#t112">112</a></span><span class="t">        <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">department</span><span class="op">.</span><span class="nam">data</span> <span class="op">!=</span> <span class="str">""</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t113" class="mis show_mis"><span class="n"><a href="#t113">113</a></span><span class="t">            <span class="nam">student</span><span class="op">.</span><span class="nam">department</span> <span class="op">=</span> <span class="nam">form</span><span class="op">.</span><span class="nam">department</span><span class="op">.</span><span class="nam">data</span>&nbsp;</span><span class="r"></span></p>
    <p id="t114" class="mis show_mis"><span class="n"><a href="#t114">114</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">add</span><span class="op">(</span><span class="nam">student</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t115" class="mis show_mis"><span class="n"><a href="#t115">115</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t116" class="mis show_mis"><span class="n"><a href="#t116">116</a></span><span class="t">        <span class="nam">flash</span><span class="op">(</span><span class="str">'&#26356;&#26032;&#23398;&#29983;&#20449;&#24687;&#25104;&#21151;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t117" class="mis show_mis"><span class="n"><a href="#t117">117</a></span><span class="t">        <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'rgs.registrar_maintain_student_information'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t118" class="mis show_mis"><span class="n"><a href="#t118">118</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_update_student.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t119" class="pln"><span class="n"><a href="#t119">119</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t120" class="pln"><span class="n"><a href="#t120">120</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t121" class="pln"><span class="n"><a href="#t121">121</a></span><span class="t"><span class="com"># --------------------</span>&nbsp;</span><span class="r"></span></p>
    <p id="t122" class="pln"><span class="n"><a href="#t122">122</a></span><span class="t"><span class="com"># &#31649;&#29702;&#25945;&#24072;&#20449;&#24687;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t123" class="pln"><span class="n"><a href="#t123">123</a></span><span class="t"><span class="com"># --------------------</span>&nbsp;</span><span class="r"></span></p>
    <p id="t124" class="pln"><span class="n"><a href="#t124">124</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t125" class="pln"><span class="n"><a href="#t125">125</a></span><span class="t"><span class="com"># &#22522;&#26412;&#31561;&#21516;&#19978;&#38754;&#23545;&#23398;&#29983;&#30340;&#25805;&#20316;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t126" class="pln"><span class="n"><a href="#t126">126</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t127" class="run"><span class="n"><a href="#t127">127</a></span><span class="t"><span class="op">@</span><span class="nam">rgs</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/registrar-maintain-professor-information'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t128" class="run"><span class="n"><a href="#t128">128</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t129" class="pln"><span class="n"><a href="#t129">129</a></span><span class="t"><span class="key">def</span> <span class="nam">registrar_maintain_professor_information</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t130" class="pln"><span class="n"><a href="#t130">130</a></span><span class="t">    <span class="com"># maintain_professor_information.html&#25552;&#20379;&#38142;&#25509;&#21040;&#28155;&#21152;&#65292;&#21024;&#38500;&#20197;&#21450;update&#25945;&#25480;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t131" class="mis show_mis"><span class="n"><a href="#t131">131</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_maintain_professor_information.html'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t132" class="pln"><span class="n"><a href="#t132">132</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t133" class="pln"><span class="n"><a href="#t133">133</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t134" class="run"><span class="n"><a href="#t134">134</a></span><span class="t"><span class="op">@</span><span class="nam">rgs</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/registrar-add-professor'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t135" class="run"><span class="n"><a href="#t135">135</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t136" class="pln"><span class="n"><a href="#t136">136</a></span><span class="t"><span class="key">def</span> <span class="nam">registrar_add_professor</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t137" class="mis show_mis"><span class="n"><a href="#t137">137</a></span><span class="t">    <span class="nam">form</span> <span class="op">=</span> <span class="nam">NewProfessorForm</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t138" class="mis show_mis"><span class="n"><a href="#t138">138</a></span><span class="t">    <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">validate_on_submit</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t139" class="mis show_mis"><span class="n"><a href="#t139">139</a></span><span class="t">        <span class="nam">professor</span> <span class="op">=</span> <span class="nam">Professor</span><span class="op">(</span><span class="nam">professor_id</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">professor_id</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t140" class="pln"><span class="n"><a href="#t140">140</a></span><span class="t">                              <span class="nam">password</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">password</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t141" class="pln"><span class="n"><a href="#t141">141</a></span><span class="t">                              <span class="nam">professor_name</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">professor_name</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t142" class="pln"><span class="n"><a href="#t142">142</a></span><span class="t">                              <span class="nam">date_of_birth</span><span class="op">=</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">strptime</span><span class="op">(</span><span class="nam">form</span><span class="op">.</span><span class="nam">date_of_birth</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span> <span class="str">'%Y-%m-%d'</span><span class="op">)</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t143" class="pln"><span class="n"><a href="#t143">143</a></span><span class="t">                              <span class="nam">social_security_number</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">social_security_number</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t144" class="pln"><span class="n"><a href="#t144">144</a></span><span class="t">                              <span class="nam">status</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">status</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t145" class="pln"><span class="n"><a href="#t145">145</a></span><span class="t">                              <span class="nam">department</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">department</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t146" class="mis show_mis"><span class="n"><a href="#t146">146</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">add</span><span class="op">(</span><span class="nam">professor</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t147" class="mis show_mis"><span class="n"><a href="#t147">147</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t148" class="mis show_mis"><span class="n"><a href="#t148">148</a></span><span class="t">        <span class="nam">flash</span><span class="op">(</span><span class="str">'&#25104;&#21151;&#28155;&#21152;&#25945;&#24072;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t149" class="mis show_mis"><span class="n"><a href="#t149">149</a></span><span class="t">        <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'rgs.registrar_maintain_professor_information'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t150" class="mis show_mis"><span class="n"><a href="#t150">150</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_add_professor.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t151" class="pln"><span class="n"><a href="#t151">151</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t152" class="pln"><span class="n"><a href="#t152">152</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t153" class="run"><span class="n"><a href="#t153">153</a></span><span class="t"><span class="op">@</span><span class="nam">rgs</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/registrar-delete-professor'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t154" class="run"><span class="n"><a href="#t154">154</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t155" class="pln"><span class="n"><a href="#t155">155</a></span><span class="t"><span class="key">def</span> <span class="nam">registrar_delete_professor</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t156" class="mis show_mis"><span class="n"><a href="#t156">156</a></span><span class="t">    <span class="nam">form</span> <span class="op">=</span> <span class="nam">ProfessorForm</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t157" class="mis show_mis"><span class="n"><a href="#t157">157</a></span><span class="t">    <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">validate_on_submit</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t158" class="mis show_mis"><span class="n"><a href="#t158">158</a></span><span class="t">        <span class="nam">professor</span> <span class="op">=</span> <span class="nam">Professor</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Professor</span><span class="op">.</span><span class="nam">professor_id</span> <span class="op">==</span> <span class="nam">form</span><span class="op">.</span><span class="nam">professor_id</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t159" class="mis show_mis"><span class="n"><a href="#t159">159</a></span><span class="t">        <span class="key">if</span> <span class="nam">professor</span> <span class="key">is</span> <span class="key">None</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t160" class="mis show_mis"><span class="n"><a href="#t160">160</a></span><span class="t">            <span class="nam">flash</span><span class="op">(</span><span class="str">'&#31995;&#32479;&#19981;&#23384;&#22312;&#35813;&#25945;&#24072;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t161" class="mis show_mis"><span class="n"><a href="#t161">161</a></span><span class="t">            <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_delete_professor.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t162" class="pln"><span class="n"><a href="#t162">162</a></span><span class="t">        <span class="com"># &#21024;&#38500;&#35813;&#25945;&#24072;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t163" class="mis show_mis"><span class="n"><a href="#t163">163</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">delete</span><span class="op">(</span><span class="nam">professor</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t164" class="mis show_mis"><span class="n"><a href="#t164">164</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t165" class="pln"><span class="n"><a href="#t165">165</a></span><span class="t">        <span class="com"># &#36825;&#37324;&#21487;&#33021;&#35201;&#32771;&#34385;&#20854;&#20182;&#34920;&#20013;&#35813;&#25945;&#24072;&#30340;&#20449;&#24687;&#20250;&#19981;&#20250;&#33258;&#21160;&#26681;&#25454;key&#26356;&#26032;&#65292;&#22914;&#26524;&#20250;&#65292;&#21017;&#19981;&#38656;&#35201;&#39069;&#22806;&#30340;&#25805;&#20316;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t166" class="mis show_mis"><span class="n"><a href="#t166">166</a></span><span class="t">        <span class="nam">flash</span><span class="op">(</span><span class="str">'&#25104;&#21151;&#21024;&#38500;&#35813;&#25945;&#24072;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t167" class="mis show_mis"><span class="n"><a href="#t167">167</a></span><span class="t">        <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'rgs.registrar_maintain_professor_information'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t168" class="mis show_mis"><span class="n"><a href="#t168">168</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_delete_professor.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t169" class="pln"><span class="n"><a href="#t169">169</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t170" class="pln"><span class="n"><a href="#t170">170</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t171" class="run"><span class="n"><a href="#t171">171</a></span><span class="t"><span class="op">@</span><span class="nam">rgs</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/registrar-update-professor'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t172" class="run"><span class="n"><a href="#t172">172</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t173" class="pln"><span class="n"><a href="#t173">173</a></span><span class="t"><span class="key">def</span> <span class="nam">registrar_update_professor</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t174" class="mis show_mis"><span class="n"><a href="#t174">174</a></span><span class="t">    <span class="nam">form</span> <span class="op">=</span> <span class="nam">UpdateProfessorForm</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t175" class="mis show_mis"><span class="n"><a href="#t175">175</a></span><span class="t">    <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">validate_on_submit</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t176" class="mis show_mis"><span class="n"><a href="#t176">176</a></span><span class="t">        <span class="nam">professor</span> <span class="op">=</span> <span class="nam">Professor</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Professor</span><span class="op">.</span><span class="nam">professor_id</span> <span class="op">==</span> <span class="nam">form</span><span class="op">.</span><span class="nam">professor_id</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t177" class="mis show_mis"><span class="n"><a href="#t177">177</a></span><span class="t">        <span class="key">if</span> <span class="nam">professor</span> <span class="key">is</span> <span class="key">None</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t178" class="mis show_mis"><span class="n"><a href="#t178">178</a></span><span class="t">            <span class="nam">flash</span><span class="op">(</span><span class="str">'&#31995;&#32479;&#19981;&#23384;&#22312;&#35813;&#25945;&#24072;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t179" class="mis show_mis"><span class="n"><a href="#t179">179</a></span><span class="t">            <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_update_professor.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t180" class="pln"><span class="n"><a href="#t180">180</a></span><span class="t">        <span class="com"># &#36825;&#37324;&#29992;if-else&#26292;&#21147;&#25628;&#32034;&#65292;&#21487;&#33021;&#20250;&#26377;&#19968;&#20123;&#38382;&#39064;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t181" class="mis show_mis"><span class="n"><a href="#t181">181</a></span><span class="t">        <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">password</span><span class="op">.</span><span class="nam">data</span> <span class="op">!=</span> <span class="str">""</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t182" class="mis show_mis"><span class="n"><a href="#t182">182</a></span><span class="t">            <span class="nam">professor</span><span class="op">.</span><span class="nam">password</span> <span class="op">=</span> <span class="nam">form</span><span class="op">.</span><span class="nam">password</span><span class="op">.</span><span class="nam">data</span>&nbsp;</span><span class="r"></span></p>
    <p id="t183" class="mis show_mis"><span class="n"><a href="#t183">183</a></span><span class="t">        <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">professor_name</span><span class="op">.</span><span class="nam">data</span> <span class="op">!=</span> <span class="str">""</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t184" class="mis show_mis"><span class="n"><a href="#t184">184</a></span><span class="t">            <span class="nam">professor</span><span class="op">.</span><span class="nam">professor_name</span> <span class="op">=</span> <span class="nam">form</span><span class="op">.</span><span class="nam">professor_name</span><span class="op">.</span><span class="nam">data</span>&nbsp;</span><span class="r"></span></p>
    <p id="t185" class="mis show_mis"><span class="n"><a href="#t185">185</a></span><span class="t">        <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">date_of_birth</span><span class="op">.</span><span class="nam">data</span> <span class="op">!=</span> <span class="str">""</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t186" class="mis show_mis"><span class="n"><a href="#t186">186</a></span><span class="t">            <span class="nam">professor</span><span class="op">.</span><span class="nam">date_of_birth</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">strptime</span><span class="op">(</span><span class="nam">form</span><span class="op">.</span><span class="nam">date_of_birth</span><span class="op">.</span><span class="nam">data</span><span class="op">,</span> <span class="str">'%Y-%m-%d'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t187" class="mis show_mis"><span class="n"><a href="#t187">187</a></span><span class="t">        <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">social_security_number</span><span class="op">.</span><span class="nam">data</span> <span class="op">!=</span> <span class="str">""</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t188" class="mis show_mis"><span class="n"><a href="#t188">188</a></span><span class="t">            <span class="nam">professor</span><span class="op">.</span><span class="nam">social_security_number</span> <span class="op">=</span> <span class="nam">form</span><span class="op">.</span><span class="nam">social_security_number</span><span class="op">.</span><span class="nam">data</span>&nbsp;</span><span class="r"></span></p>
    <p id="t189" class="mis show_mis"><span class="n"><a href="#t189">189</a></span><span class="t">        <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">status</span><span class="op">.</span><span class="nam">data</span> <span class="op">!=</span> <span class="str">""</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t190" class="mis show_mis"><span class="n"><a href="#t190">190</a></span><span class="t">            <span class="nam">professor</span><span class="op">.</span><span class="nam">status</span> <span class="op">=</span> <span class="nam">form</span><span class="op">.</span><span class="nam">status</span><span class="op">.</span><span class="nam">data</span>&nbsp;</span><span class="r"></span></p>
    <p id="t191" class="mis show_mis"><span class="n"><a href="#t191">191</a></span><span class="t">        <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">department</span><span class="op">.</span><span class="nam">data</span> <span class="op">!=</span> <span class="str">""</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t192" class="mis show_mis"><span class="n"><a href="#t192">192</a></span><span class="t">            <span class="nam">professor</span><span class="op">.</span><span class="nam">department</span> <span class="op">=</span> <span class="nam">form</span><span class="op">.</span><span class="nam">department</span><span class="op">.</span><span class="nam">data</span>&nbsp;</span><span class="r"></span></p>
    <p id="t193" class="mis show_mis"><span class="n"><a href="#t193">193</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">add</span><span class="op">(</span><span class="nam">professor</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t194" class="mis show_mis"><span class="n"><a href="#t194">194</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t195" class="mis show_mis"><span class="n"><a href="#t195">195</a></span><span class="t">        <span class="nam">flash</span><span class="op">(</span><span class="str">'&#26356;&#26032;&#25945;&#24072;&#20449;&#24687;&#25104;&#21151;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t196" class="mis show_mis"><span class="n"><a href="#t196">196</a></span><span class="t">        <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'rgs.registrar_maintain_professor_information'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t197" class="mis show_mis"><span class="n"><a href="#t197">197</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_update_professor.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t198" class="pln"><span class="n"><a href="#t198">198</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t199" class="pln"><span class="n"><a href="#t199">199</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t200" class="pln"><span class="n"><a href="#t200">200</a></span><span class="t"><span class="com"># ---------------------------</span>&nbsp;</span><span class="r"></span></p>
    <p id="t201" class="pln"><span class="n"><a href="#t201">201</a></span><span class="t"><span class="com"># &#20851;&#38381;&#36873;&#35838;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t202" class="pln"><span class="n"><a href="#t202">202</a></span><span class="t"><span class="com"># ---------------------------</span>&nbsp;</span><span class="r"></span></p>
    <p id="t203" class="pln"><span class="n"><a href="#t203">203</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t204" class="pln"><span class="n"><a href="#t204">204</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t205" class="run"><span class="n"><a href="#t205">205</a></span><span class="t"><span class="op">@</span><span class="nam">rgs</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/registrar-list-course-to-cancel'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t206" class="run"><span class="n"><a href="#t206">206</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t207" class="pln"><span class="n"><a href="#t207">207</a></span><span class="t"><span class="key">def</span> <span class="nam">registrar_list_course_to_cancel</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t208" class="pln"><span class="n"><a href="#t208">208</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#20026;&#31649;&#29702;&#21592;&#21015;&#20986;&#27492;&#26102;&#27492;&#21051;&#36873;&#35838;&#20154;&#25968;&#23567;&#20110;3&#20154;&#30340;&#35838;&#31243;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t209" class="pln"><span class="n"><a href="#t209">209</a></span><span class="t">    <span class="com"># &#31561;&#21040;&#35268;&#23450;&#26102;&#38388;&#65292;&#31649;&#29702;&#21592;&#23601;&#21487;&#20197;&#36827;&#34892;&#25805;&#20316;&#65292;&#20294;&#22312;&#36873;&#35838;&#32467;&#26463;&#20043;&#21069;&#65292;&#20063;&#32473;&#31649;&#29702;&#21592;&#21015;&#20986;&#26469;&#65292;&#31649;&#29702;&#21592;&#33021;&#30475;&#35265;&#65292;&#20294;&#20182;&#19981;&#20250;&#36825;&#20010;&#26102;&#20505;&#21435;&#21462;&#28040;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t210" class="pln"><span class="n"><a href="#t210">210</a></span><span class="t">    <span class="com"># &#36825;&#19968;&#28857;&#19981;&#24402;&#31995;&#32479;&#31649;&#65292;&#23436;&#20840;&#26159;&#20154;&#20026;&#25805;&#20316;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t211" class="pln"><span class="n"><a href="#t211">211</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t212" class="pln"><span class="n"><a href="#t212">212</a></span><span class="t">    <span class="com"># &#26597;&#35810;&#25968;&#25454;&#24211;&#65292;&#21015;&#20986;&#20154;&#25968;&#23567;&#20110;3&#20154;&#30340;&#35838;&#31243;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t213" class="pln"><span class="n"><a href="#t213">213</a></span><span class="t">    <span class="com"># select course_id</span>&nbsp;</span><span class="r"></span></p>
    <p id="t214" class="pln"><span class="n"><a href="#t214">214</a></span><span class="t">    <span class="com"># from (select course_id, count(*) as amount</span>&nbsp;</span><span class="r"></span></p>
    <p id="t215" class="pln"><span class="n"><a href="#t215">215</a></span><span class="t">    <span class="com"># from takes</span>&nbsp;</span><span class="r"></span></p>
    <p id="t216" class="pln"><span class="n"><a href="#t216">216</a></span><span class="t">    <span class="com"># where isPrimary = True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t217" class="pln"><span class="n"><a href="#t217">217</a></span><span class="t">    <span class="com"># group by course_id) temp</span>&nbsp;</span><span class="r"></span></p>
    <p id="t218" class="pln"><span class="n"><a href="#t218">218</a></span><span class="t">    <span class="com"># where temp.amount &lt; 3</span>&nbsp;</span><span class="r"></span></p>
    <p id="t219" class="pln"><span class="n"><a href="#t219">219</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t220" class="mis show_mis"><span class="n"><a href="#t220">220</a></span><span class="t">    <span class="nam">dic</span> <span class="op">=</span> <span class="nam">dict</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t221" class="mis show_mis"><span class="n"><a href="#t221">221</a></span><span class="t">    <span class="nam">takes</span> <span class="op">=</span> <span class="nam">Takes</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">isPrimary</span> <span class="op">==</span> <span class="key">True</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t222" class="mis show_mis"><span class="n"><a href="#t222">222</a></span><span class="t">    <span class="key">for</span> <span class="nam">take</span> <span class="key">in</span> <span class="nam">takes</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t223" class="mis show_mis"><span class="n"><a href="#t223">223</a></span><span class="t">        <span class="key">if</span> <span class="nam">take</span><span class="op">.</span><span class="nam">section_id</span> <span class="key">in</span> <span class="nam">dic</span><span class="op">.</span><span class="nam">keys</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t224" class="mis show_mis"><span class="n"><a href="#t224">224</a></span><span class="t">            <span class="nam">dic</span><span class="op">[</span><span class="nam">take</span><span class="op">.</span><span class="nam">section_id</span><span class="op">]</span> <span class="op">+=</span> <span class="num">1</span>&nbsp;</span><span class="r"></span></p>
    <p id="t225" class="pln"><span class="n"><a href="#t225">225</a></span><span class="t">        <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t226" class="mis show_mis"><span class="n"><a href="#t226">226</a></span><span class="t">            <span class="nam">dic</span><span class="op">[</span><span class="nam">take</span><span class="op">.</span><span class="nam">section_id</span><span class="op">]</span> <span class="op">=</span> <span class="num">1</span>&nbsp;</span><span class="r"></span></p>
    <p id="t227" class="pln"><span class="n"><a href="#t227">227</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t228" class="mis show_mis"><span class="n"><a href="#t228">228</a></span><span class="t">    <span class="nam">section_ids</span> <span class="op">=</span> <span class="op">[</span><span class="nam">item</span> <span class="key">for</span> <span class="nam">item</span> <span class="key">in</span> <span class="nam">dic</span><span class="op">.</span><span class="nam">keys</span><span class="op">(</span><span class="op">)</span> <span class="key">if</span> <span class="nam">dic</span><span class="op">[</span><span class="nam">item</span><span class="op">]</span> <span class="op">&lt;</span> <span class="num">3</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t229" class="pln"><span class="n"><a href="#t229">229</a></span><span class="t">    <span class="com"># &#36825;&#26679;&#21482;&#21253;&#21547;&#20102;&#36873;&#35838;&#20154;&#25968;&#20026;1-2&#20154;&#30340;&#35838;&#31243;&#65292;&#20026;&#38646;&#20154;&#30340;&#35838;&#31243;&#38656;&#35201;&#21333;&#29420;&#32771;&#34385;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t230" class="pln"><span class="n"><a href="#t230">230</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t231" class="mis show_mis"><span class="n"><a href="#t231">231</a></span><span class="t">    <span class="nam">sections_with_0_registration</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t232" class="mis show_mis"><span class="n"><a href="#t232">232</a></span><span class="t">    <span class="nam">all_sections</span> <span class="op">=</span> <span class="nam">Section</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t233" class="mis show_mis"><span class="n"><a href="#t233">233</a></span><span class="t">    <span class="key">for</span> <span class="nam">section</span> <span class="key">in</span> <span class="nam">all_sections</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t234" class="mis show_mis"><span class="n"><a href="#t234">234</a></span><span class="t">        <span class="key">if</span> <span class="nam">section</span><span class="op">.</span><span class="nam">section_id</span> <span class="key">not</span> <span class="key">in</span> <span class="nam">dic</span><span class="op">.</span><span class="nam">keys</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t235" class="mis show_mis"><span class="n"><a href="#t235">235</a></span><span class="t">            <span class="nam">sections_with_0_registration</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">section</span><span class="op">.</span><span class="nam">section_id</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t236" class="pln"><span class="n"><a href="#t236">236</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t237" class="mis show_mis"><span class="n"><a href="#t237">237</a></span><span class="t">    <span class="nam">section_ids</span> <span class="op">=</span> <span class="nam">section_ids</span> <span class="op">+</span> <span class="nam">sections_with_0_registration</span>&nbsp;</span><span class="r"></span></p>
    <p id="t238" class="pln"><span class="n"><a href="#t238">238</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t239" class="pln"><span class="n"><a href="#t239">239</a></span><span class="t">    <span class="com"># &#21152;&#20837;&#27809;&#26377;&#32769;&#24072;&#25945;&#30340;sections</span>&nbsp;</span><span class="r"></span></p>
    <p id="t240" class="mis show_mis"><span class="n"><a href="#t240">240</a></span><span class="t">    <span class="nam">section_with_0_professor</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t241" class="mis show_mis"><span class="n"><a href="#t241">241</a></span><span class="t">    <span class="nam">all_teaches</span> <span class="op">=</span> <span class="nam">Teaches</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t242" class="mis show_mis"><span class="n"><a href="#t242">242</a></span><span class="t">    <span class="nam">taught_section_ids</span> <span class="op">=</span> <span class="op">[</span><span class="nam">teach</span><span class="op">.</span><span class="nam">section_id</span> <span class="key">for</span> <span class="nam">teach</span> <span class="key">in</span> <span class="nam">all_teaches</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t243" class="mis show_mis"><span class="n"><a href="#t243">243</a></span><span class="t">    <span class="key">for</span> <span class="nam">section</span> <span class="key">in</span> <span class="nam">all_sections</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t244" class="mis show_mis"><span class="n"><a href="#t244">244</a></span><span class="t">        <span class="key">if</span> <span class="nam">section</span><span class="op">.</span><span class="nam">section_id</span> <span class="key">not</span> <span class="key">in</span> <span class="nam">taught_section_ids</span> <span class="key">and</span> <span class="nam">section</span><span class="op">.</span><span class="nam">section_id</span> <span class="key">not</span> <span class="key">in</span> <span class="nam">section_ids</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t245" class="mis show_mis"><span class="n"><a href="#t245">245</a></span><span class="t">            <span class="nam">section_with_0_professor</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">section</span><span class="op">.</span><span class="nam">section_id</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t246" class="pln"><span class="n"><a href="#t246">246</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t247" class="mis show_mis"><span class="n"><a href="#t247">247</a></span><span class="t">    <span class="nam">section_ids</span> <span class="op">=</span> <span class="nam">section_ids</span> <span class="op">+</span> <span class="nam">section_with_0_professor</span>&nbsp;</span><span class="r"></span></p>
    <p id="t248" class="pln"><span class="n"><a href="#t248">248</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t249" class="pln"><span class="n"><a href="#t249">249</a></span><span class="t">    <span class="com"># if len(section_ids)==0:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t250" class="pln"><span class="n"><a href="#t250">250</a></span><span class="t">    <span class="com">#     flash('len(section_ids)==0')</span>&nbsp;</span><span class="r"></span></p>
    <p id="t251" class="pln"><span class="n"><a href="#t251">251</a></span><span class="t">    <span class="com"># temp = Takes.query(Takes.section_id, func.count(Takes.section_id).label('amount')).filter(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t252" class="pln"><span class="n"><a href="#t252">252</a></span><span class="t">    <span class="com">#     Takes.isPrimary).group_by(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t253" class="pln"><span class="n"><a href="#t253">253</a></span><span class="t">    <span class="com">#     Takes.section_id).all()</span>&nbsp;</span><span class="r"></span></p>
    <p id="t254" class="pln"><span class="n"><a href="#t254">254</a></span><span class="t">    <span class="com"># sections_ids = db.session.query(temp).filter(temp.amount &lt; 3).all()</span>&nbsp;</span><span class="r"></span></p>
    <p id="t255" class="mis show_mis"><span class="n"><a href="#t255">255</a></span><span class="t">    <span class="nam">sections_with_less_than_3_capacity</span> <span class="op">=</span> <span class="nam">Section</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Section</span><span class="op">.</span><span class="nam">section_id</span><span class="op">.</span><span class="nam">in_</span><span class="op">(</span><span class="nam">section_ids</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t256" class="pln"><span class="n"><a href="#t256">256</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t257" class="mis show_mis"><span class="n"><a href="#t257">257</a></span><span class="t">    <span class="nam">section_list</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t258" class="mis show_mis"><span class="n"><a href="#t258">258</a></span><span class="t">    <span class="key">for</span> <span class="nam">section</span> <span class="key">in</span> <span class="nam">sections_with_less_than_3_capacity</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t259" class="mis show_mis"><span class="n"><a href="#t259">259</a></span><span class="t">        <span class="nam">course</span> <span class="op">=</span> <span class="nam">Course</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Course</span><span class="op">.</span><span class="nam">course_id</span> <span class="op">==</span> <span class="nam">section</span><span class="op">.</span><span class="nam">course_id</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t260" class="mis show_mis"><span class="n"><a href="#t260">260</a></span><span class="t">        <span class="key">if</span> <span class="nam">course</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span><span class="op">:</span>  <span class="com"># &#22240;&#20026;&#26377;&#22806;&#38190;&#35774;&#32622;&#25152;&#20197;&#23454;&#38469;&#19978;&#26159;&#19981;&#20250;&#20026;&#31354;&#30340;&#65292;&#20294;&#32771;&#34385;&#21040;&#25968;&#25454;&#24211;&#30340;&#21021;&#22987;&#25968;&#25454;&#26159;&#33258;&#24049;&#21152;&#30340;&#65292;&#25152;&#20197;&#21487;&#33021;&#26377;&#30095;&#28431;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t261" class="mis show_mis"><span class="n"><a href="#t261">261</a></span><span class="t">            <span class="nam">section_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">section</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t262" class="pln"><span class="n"><a href="#t262">262</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t263" class="pln"><span class="n"><a href="#t263">263</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#20165;&#26597;&#35810;&#25968;&#25454;&#65292;&#20132;&#32473;&#21069;&#31471;&#65292;&#21069;&#31471;&#20026;&#27599;&#38376;&#35838;&#25552;&#20379;&#38142;&#25509;&#21040;&#19979;&#19968;&#20010;&#36335;&#30001;&#65292;&#21363;rgs.registrar_cancel_course</span>&nbsp;</span><span class="r"></span></p>
    <p id="t264" class="pln"><span class="n"><a href="#t264">264</a></span><span class="t">    <span class="com"># &#22240;&#20026;&#19979;&#19968;&#20010;&#36335;&#30001;&#65292;&#21363;rgs.registrar_cancel_course&#38656;&#35201;section_id&#20316;&#20026;&#21442;&#25968;&#65292;&#25152;&#20197;&#26412;&#36335;&#30001;&#36820;&#22238;&#21040;&#21069;&#31471;&#30340;&#25968;&#25454;&#26368;&#22909;&#26159;&#35838;&#31243;&#23454;&#20363;&#30340;&#21015;&#34920;&#65292;&#24517;&#39035;&#21253;&#21547;&#35838;&#31243;id</span>&nbsp;</span><span class="r"></span></p>
    <p id="t265" class="mis show_mis"><span class="n"><a href="#t265">265</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_list_course_to_cancel.html'</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t266" class="pln"><span class="n"><a href="#t266">266</a></span><span class="t">                           <span class="nam">section_list</span><span class="op">=</span><span class="nam">section_list</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t267" class="pln"><span class="n"><a href="#t267">267</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t268" class="pln"><span class="n"><a href="#t268">268</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t269" class="run"><span class="n"><a href="#t269">269</a></span><span class="t"><span class="op">@</span><span class="nam">rgs</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/registrar-cancel-course/&lt;int:section_id>'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t270" class="run"><span class="n"><a href="#t270">270</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t271" class="pln"><span class="n"><a href="#t271">271</a></span><span class="t"><span class="key">def</span> <span class="nam">registrar_cancel_course</span><span class="op">(</span><span class="nam">section_id</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t272" class="pln"><span class="n"><a href="#t272">272</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#21462;&#28040;&#32473;&#23450;section_id&#30340;&#35838;&#31243;&#65292;&#24182;&#23558;&#26032;&#30340;&#28040;&#24687;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t273" class="mis show_mis"><span class="n"><a href="#t273">273</a></span><span class="t">    <span class="nam">message_body</span> <span class="op">=</span> <span class="str">"&#35838;&#31243;["</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">section_id</span><span class="op">)</span> <span class="op">+</span> <span class="str">"]&#22240;&#36873;&#35838;&#20154;&#25968;&#19981;&#36275;&#65292;&#24050;&#34987;&#21462;&#28040;&#65281;"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t274" class="pln"><span class="n"><a href="#t274">274</a></span><span class="t">    <span class="com"># &#36825;&#37324;&#30340;&#25552;&#31034;&#20449;&#24687;&#38656;&#35201;&#25913;&#19968;&#19979;&#30452;&#25509;&#25253;&#19978;&#21435;section_id&#26377;&#28857;&#31361;&#20800;&#65292;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t275" class="pln"><span class="n"><a href="#t275">275</a></span><span class="t">    <span class="com"># &#21487;&#20197;&#26159;&#25351;&#20986;&#35838;&#31243;&#21517;&#21644;&#35838;&#31243;&#30340;&#23398;&#26399;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t276" class="pln"><span class="n"><a href="#t276">276</a></span><span class="t">    <span class="com"># &#28155;&#21152;&#21040;input_box&#20013;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t277" class="pln"><span class="n"><a href="#t277">277</a></span><span class="t">    <span class="com"># &#38500;&#27492;&#20043;&#22806;&#65292;&#36824;&#38656;&#23558;&#23398;&#29983;&#30340;&#22791;&#36873;&#35838;(&#38656;&#26597;&#35810;takes&#34920;&#65292;&#26816;&#26597;isPrimary&#65289;&#32473;&#20182;&#25442;&#25104;&#23454;&#38469;&#30340;&#35838;&#31243;&#65288;&#23558;isPrimary&#32622;&#20026;True&#65289;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t278" class="pln"><span class="n"><a href="#t278">278</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t279" class="pln"><span class="n"><a href="#t279">279</a></span><span class="t">    <span class="com"># &#27493;&#39588;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t280" class="pln"><span class="n"><a href="#t280">280</a></span><span class="t">    <span class="com"># 1. &#26597;&#21040;&#36873;&#36825;&#38376;&#35838;&#30340;&#25152;&#26377;&#23398;&#29983; students</span>&nbsp;</span><span class="r"></span></p>
    <p id="t281" class="pln"><span class="n"><a href="#t281">281</a></span><span class="t">    <span class="com"># student_ids = Takes.query(Takes.student_id).filter(Takes.section_id == section_id).all()</span>&nbsp;</span><span class="r"></span></p>
    <p id="t282" class="mis show_mis"><span class="n"><a href="#t282">282</a></span><span class="t">    <span class="nam">student_takes</span> <span class="op">=</span> <span class="nam">Takes</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">section_id</span> <span class="op">==</span> <span class="nam">section_id</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t283" class="mis show_mis"><span class="n"><a href="#t283">283</a></span><span class="t">    <span class="nam">student_ids</span> <span class="op">=</span> <span class="op">[</span><span class="nam">take</span><span class="op">.</span><span class="nam">section_id</span> <span class="key">for</span> <span class="nam">take</span> <span class="key">in</span> <span class="nam">student_takes</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t284" class="pln"><span class="n"><a href="#t284">284</a></span><span class="t">    <span class="com"># 2. &#26597;&#21040;&#36873;&#36825;&#38376;&#35838;&#30340;&#25152;&#26377;&#32769;&#24072; professors</span>&nbsp;</span><span class="r"></span></p>
    <p id="t285" class="pln"><span class="n"><a href="#t285">285</a></span><span class="t">    <span class="com"># professor_ids = Teaches.query(Teaches.professor_id).filter(Teaches.course_id == section_id).all()</span>&nbsp;</span><span class="r"></span></p>
    <p id="t286" class="mis show_mis"><span class="n"><a href="#t286">286</a></span><span class="t">    <span class="nam">professor_teaches</span> <span class="op">=</span> <span class="nam">Teaches</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Teaches</span><span class="op">.</span><span class="nam">section_id</span> <span class="op">==</span> <span class="nam">section_id</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t287" class="mis show_mis"><span class="n"><a href="#t287">287</a></span><span class="t">    <span class="nam">professor_ids</span> <span class="op">=</span> <span class="op">[</span><span class="nam">teach</span><span class="op">.</span><span class="nam">professor_id</span> <span class="key">for</span> <span class="nam">teach</span> <span class="key">in</span> <span class="nam">professor_teaches</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t288" class="pln"><span class="n"><a href="#t288">288</a></span><span class="t">    <span class="com"># 3. &#28155;&#21152;&#21040;input_box</span>&nbsp;</span><span class="r"></span></p>
    <p id="t289" class="mis show_mis"><span class="n"><a href="#t289">289</a></span><span class="t">    <span class="key">for</span> <span class="nam">student_id</span> <span class="key">in</span> <span class="nam">student_ids</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t290" class="mis show_mis"><span class="n"><a href="#t290">290</a></span><span class="t">        <span class="nam">input_box</span> <span class="op">=</span> <span class="nam">Inputbox</span><span class="op">(</span><span class="nam">user_id</span><span class="op">=</span><span class="nam">student_id</span><span class="op">,</span> <span class="nam">message</span><span class="op">=</span><span class="nam">message_body</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t291" class="mis show_mis"><span class="n"><a href="#t291">291</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">add</span><span class="op">(</span><span class="nam">input_box</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t292" class="pln"><span class="n"><a href="#t292">292</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t293" class="mis show_mis"><span class="n"><a href="#t293">293</a></span><span class="t">    <span class="key">for</span> <span class="nam">professor_id</span> <span class="key">in</span> <span class="nam">professor_ids</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t294" class="mis show_mis"><span class="n"><a href="#t294">294</a></span><span class="t">        <span class="nam">input_box</span> <span class="op">=</span> <span class="nam">Inputbox</span><span class="op">(</span><span class="nam">user_id</span><span class="op">=</span><span class="nam">professor_id</span><span class="op">,</span> <span class="nam">message</span><span class="op">=</span><span class="nam">message_body</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t295" class="mis show_mis"><span class="n"><a href="#t295">295</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">add</span><span class="op">(</span><span class="nam">input_box</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t296" class="pln"><span class="n"><a href="#t296">296</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t297" class="mis show_mis"><span class="n"><a href="#t297">297</a></span><span class="t">    <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t298" class="pln"><span class="n"><a href="#t298">298</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t299" class="pln"><span class="n"><a href="#t299">299</a></span><span class="t">    <span class="com"># &#22788;&#29702;&#23398;&#29983;&#22791;&#36873;&#35838;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t300" class="mis show_mis"><span class="n"><a href="#t300">300</a></span><span class="t">    <span class="key">for</span> <span class="nam">student_id</span> <span class="key">in</span> <span class="nam">student_ids</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t301" class="mis show_mis"><span class="n"><a href="#t301">301</a></span><span class="t">        <span class="nam">takes</span> <span class="op">=</span> <span class="nam">Takes</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">student_id</span> <span class="op">==</span> <span class="nam">student_id</span><span class="op">,</span> <span class="nam">Takes</span><span class="op">.</span><span class="nam">isPrimary</span> <span class="op">==</span> <span class="key">False</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t302" class="mis show_mis"><span class="n"><a href="#t302">302</a></span><span class="t">        <span class="key">if</span> <span class="nam">len</span><span class="op">(</span><span class="nam">takes</span><span class="op">)</span> <span class="op">></span> <span class="num">0</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t303" class="pln"><span class="n"><a href="#t303">303</a></span><span class="t">            <span class="com"># &#35813;&#23398;&#29983;&#26377;&#22791;&#36873;&#35838;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t304" class="mis show_mis"><span class="n"><a href="#t304">304</a></span><span class="t">            <span class="key">for</span> <span class="nam">take</span> <span class="key">in</span> <span class="nam">takes</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t305" class="pln"><span class="n"><a href="#t305">305</a></span><span class="t">                <span class="com"># &#26597;&#21040;&#36873;&#35838;&#30340;&#20154;&#25968;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t306" class="pln"><span class="n"><a href="#t306">306</a></span><span class="t">                <span class="com"># temp = Takes.query(func.count(Takes.takes_id).label('amount')).filter(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t307" class="pln"><span class="n"><a href="#t307">307</a></span><span class="t">                <span class="com">#     Takes.section_id == take.section_id).filter(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t308" class="pln"><span class="n"><a href="#t308">308</a></span><span class="t">                <span class="com">#     Takes.isPrimary == True).first()</span>&nbsp;</span><span class="r"></span></p>
    <p id="t309" class="pln"><span class="n"><a href="#t309">309</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t310" class="mis show_mis"><span class="n"><a href="#t310">310</a></span><span class="t">                <span class="nam">all_primary_takes</span> <span class="op">=</span> <span class="nam">Takes</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">section_id</span> <span class="op">==</span> <span class="nam">take</span><span class="op">.</span><span class="nam">section_id</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t311" class="pln"><span class="n"><a href="#t311">311</a></span><span class="t">                                                       <span class="nam">Takes</span><span class="op">.</span><span class="nam">isPrimary</span> <span class="op">==</span> <span class="key">True</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t312" class="mis show_mis"><span class="n"><a href="#t312">312</a></span><span class="t">                <span class="nam">primary_takes_list</span> <span class="op">=</span> <span class="op">[</span><span class="nam">primary_take</span><span class="op">.</span><span class="nam">takes_id</span> <span class="key">for</span> <span class="nam">primary_take</span> <span class="key">in</span> <span class="nam">all_primary_takes</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t313" class="pln"><span class="n"><a href="#t313">313</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t314" class="mis show_mis"><span class="n"><a href="#t314">314</a></span><span class="t">                <span class="key">if</span> <span class="nam">len</span><span class="op">(</span><span class="nam">primary_takes_list</span><span class="op">)</span> <span class="op">&lt;</span> <span class="num">10</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t315" class="pln"><span class="n"><a href="#t315">315</a></span><span class="t">                    <span class="com"># &#22914;&#26524;&#28385;&#36275;&#26465;&#20214;&#21017;&#21487;&#20197;&#36873;&#35838;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t316" class="mis show_mis"><span class="n"><a href="#t316">316</a></span><span class="t">                    <span class="nam">take</span><span class="op">.</span><span class="nam">isPrimary</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t317" class="pln"><span class="n"><a href="#t317">317</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t318" class="mis show_mis"><span class="n"><a href="#t318">318</a></span><span class="t">            <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t319" class="pln"><span class="n"><a href="#t319">319</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t320" class="pln"><span class="n"><a href="#t320">320</a></span><span class="t">        <span class="com"># &#21040;&#36825;&#37324;&#65292;&#35813;&#23398;&#29983;&#26080;&#22791;&#36873;&#35838;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t321" class="pln"><span class="n"><a href="#t321">321</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t322" class="pln"><span class="n"><a href="#t322">322</a></span><span class="t">    <span class="com"># &#28982;&#21518;&#21024;&#38500;&#35813;section</span>&nbsp;</span><span class="r"></span></p>
    <p id="t323" class="mis show_mis"><span class="n"><a href="#t323">323</a></span><span class="t">    <span class="nam">section</span> <span class="op">=</span> <span class="nam">Section</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Section</span><span class="op">.</span><span class="nam">section_id</span> <span class="op">==</span> <span class="nam">section_id</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t324" class="mis show_mis"><span class="n"><a href="#t324">324</a></span><span class="t">    <span class="key">if</span> <span class="nam">section</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t325" class="mis show_mis"><span class="n"><a href="#t325">325</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">delete</span><span class="op">(</span><span class="nam">section</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t326" class="mis show_mis"><span class="n"><a href="#t326">326</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t327" class="mis show_mis"><span class="n"><a href="#t327">327</a></span><span class="t">        <span class="nam">flash</span><span class="op">(</span><span class="str">'&#24744;&#24050;&#25104;&#21151;&#21462;&#28040;&#35813;&#35838;&#31243;&#65281;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t328" class="pln"><span class="n"><a href="#t328">328</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t329" class="pln"><span class="n"><a href="#t329">329</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#26080;&#23454;&#38469;&#30028;&#38754;&#65292;&#20165;&#29992;&#20110;&#22788;&#29702;&#25968;&#25454;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t330" class="pln"><span class="n"><a href="#t330">330</a></span><span class="t">    <span class="com"># &#22788;&#29702;&#23436;&#25104;&#21518;&#65292;&#36820;&#22238;&#21040;rgs.registrar_list_course_to_cancel</span>&nbsp;</span><span class="r"></span></p>
    <p id="t331" class="mis show_mis"><span class="n"><a href="#t331">331</a></span><span class="t">    <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'rgs.registrar_list_course_to_cancel'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t332" class="pln"><span class="n"><a href="#t332">332</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t333" class="pln"><span class="n"><a href="#t333">333</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t334" class="pln"><span class="n"><a href="#t334">334</a></span><span class="t"><span class="com"># --------------------------------</span>&nbsp;</span><span class="r"></span></p>
    <p id="t335" class="pln"><span class="n"><a href="#t335">335</a></span><span class="t"><span class="com"># &#26597;&#30475;&#23398;&#29983;&#20449;&#24687;&#37096;&#20998;&#65292;&#36825;&#37096;&#20998;&#20854;&#23454;&#27809;&#26377;&#35201;&#27714;&#65292;&#20294;&#20026;&#20102;&#26041;&#20415;&#28436;&#31034;&#21644;&#23454;&#38469;&#38656;&#35201;&#65292;&#34917;&#20805;&#20102;&#36825;&#19968;&#37096;&#20998;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t336" class="pln"><span class="n"><a href="#t336">336</a></span><span class="t"><span class="com"># --------------------------------</span>&nbsp;</span><span class="r"></span></p>
    <p id="t337" class="run"><span class="n"><a href="#t337">337</a></span><span class="t"><span class="op">@</span><span class="nam">rgs</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/registrar-lookup-professor'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t338" class="run"><span class="n"><a href="#t338">338</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t339" class="pln"><span class="n"><a href="#t339">339</a></span><span class="t"><span class="key">def</span> <span class="nam">registrar_lookup_professor</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t340" class="mis show_mis"><span class="n"><a href="#t340">340</a></span><span class="t">    <span class="nam">form</span> <span class="op">=</span> <span class="nam">ProfessorForm</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t341" class="pln"><span class="n"><a href="#t341">341</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t342" class="mis show_mis"><span class="n"><a href="#t342">342</a></span><span class="t">    <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">validate_on_submit</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t343" class="mis show_mis"><span class="n"><a href="#t343">343</a></span><span class="t">        <span class="nam">professor</span> <span class="op">=</span> <span class="nam">Professor</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Professor</span><span class="op">.</span><span class="nam">professor_id</span> <span class="op">==</span> <span class="nam">form</span><span class="op">.</span><span class="nam">professor_id</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t344" class="mis show_mis"><span class="n"><a href="#t344">344</a></span><span class="t">        <span class="key">if</span> <span class="nam">professor</span> <span class="key">is</span> <span class="key">None</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t345" class="mis show_mis"><span class="n"><a href="#t345">345</a></span><span class="t">            <span class="nam">flash</span><span class="op">(</span><span class="str">'&#26597;&#35810;&#22833;&#36133;&#65281;&#31995;&#32479;&#19981;&#23384;&#22312;&#35813;&#25945;&#24072;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t346" class="mis show_mis"><span class="n"><a href="#t346">346</a></span><span class="t">            <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_lookup_professor.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">,</span> <span class="nam">information_list</span><span class="op">=</span><span class="key">None</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t347" class="pln"><span class="n"><a href="#t347">347</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t348" class="pln"><span class="n"><a href="#t348">348</a></span><span class="t">        <span class="com"># &#21015;&#20986;&#20449;&#24687;&#35813;&#25945;&#24072;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t349" class="mis show_mis"><span class="n"><a href="#t349">349</a></span><span class="t">        <span class="nam">information_list</span> <span class="op">=</span> <span class="op">[</span><span class="op">[</span><span class="str">'&#25945;&#32844;&#24037;&#21495;'</span><span class="op">,</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">professor_id</span><span class="op">]</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t350" class="mis show_mis"><span class="n"><a href="#t350">350</a></span><span class="t">        <span class="key">if</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">professor_name</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span> <span class="key">and</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">professor_name</span> <span class="op">!=</span> <span class="str">''</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t351" class="mis show_mis"><span class="n"><a href="#t351">351</a></span><span class="t">            <span class="nam">information_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="op">[</span><span class="str">'&#25945;&#24072;&#22995;&#21517;'</span><span class="op">,</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">professor_name</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t352" class="mis show_mis"><span class="n"><a href="#t352">352</a></span><span class="t">        <span class="key">if</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">date_of_birth</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t353" class="mis show_mis"><span class="n"><a href="#t353">353</a></span><span class="t">            <span class="nam">birthday</span> <span class="op">=</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">date_of_birth</span>&nbsp;</span><span class="r"></span></p>
    <p id="t354" class="mis show_mis"><span class="n"><a href="#t354">354</a></span><span class="t">            <span class="nam">birthday_str</span> <span class="op">=</span> <span class="nam">str</span><span class="op">(</span><span class="nam">birthday</span><span class="op">.</span><span class="nam">year</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#24180;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">birthday</span><span class="op">.</span><span class="nam">month</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#26376;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">birthday</span><span class="op">.</span><span class="nam">day</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#26085;"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t355" class="mis show_mis"><span class="n"><a href="#t355">355</a></span><span class="t">            <span class="nam">information_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="op">[</span><span class="str">'&#20986;&#29983;&#26085;&#26399;'</span><span class="op">,</span> <span class="nam">birthday_str</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t356" class="mis show_mis"><span class="n"><a href="#t356">356</a></span><span class="t">        <span class="key">if</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">department</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span> <span class="key">and</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">department</span> <span class="op">!=</span> <span class="str">''</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t357" class="mis show_mis"><span class="n"><a href="#t357">357</a></span><span class="t">            <span class="nam">information_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="op">[</span><span class="str">'&#23398;&#38498;'</span><span class="op">,</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">department</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t358" class="mis show_mis"><span class="n"><a href="#t358">358</a></span><span class="t">        <span class="key">if</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">status</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span> <span class="key">and</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">status</span> <span class="op">!=</span> <span class="str">''</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t359" class="mis show_mis"><span class="n"><a href="#t359">359</a></span><span class="t">            <span class="nam">information_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="op">[</span><span class="str">'&#32844;&#31216;'</span><span class="op">,</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">status</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t360" class="mis show_mis"><span class="n"><a href="#t360">360</a></span><span class="t">        <span class="key">if</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">social_security_number</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span> <span class="key">and</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">social_security_number</span> <span class="op">!=</span> <span class="str">''</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t361" class="mis show_mis"><span class="n"><a href="#t361">361</a></span><span class="t">            <span class="nam">information_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="op">[</span><span class="str">'&#36523;&#20221;&#35777;&#21495;&#30721;'</span><span class="op">,</span> <span class="nam">professor</span><span class="op">.</span><span class="nam">social_security_number</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t362" class="pln"><span class="n"><a href="#t362">362</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t363" class="mis show_mis"><span class="n"><a href="#t363">363</a></span><span class="t">        <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_lookup_professor.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t364" class="pln"><span class="n"><a href="#t364">364</a></span><span class="t">                               <span class="nam">information_list</span><span class="op">=</span><span class="nam">information_list</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t365" class="mis show_mis"><span class="n"><a href="#t365">365</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_lookup_professor.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">,</span> <span class="nam">information_list</span><span class="op">=</span><span class="key">None</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t366" class="pln"><span class="n"><a href="#t366">366</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t367" class="pln"><span class="n"><a href="#t367">367</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t368" class="run"><span class="n"><a href="#t368">368</a></span><span class="t"><span class="op">@</span><span class="nam">rgs</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/registrar-lookup-student'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t369" class="run"><span class="n"><a href="#t369">369</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t370" class="pln"><span class="n"><a href="#t370">370</a></span><span class="t"><span class="key">def</span> <span class="nam">registrar_lookup_student</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t371" class="mis show_mis"><span class="n"><a href="#t371">371</a></span><span class="t">    <span class="nam">form</span> <span class="op">=</span> <span class="nam">StudentForm</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t372" class="pln"><span class="n"><a href="#t372">372</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t373" class="mis show_mis"><span class="n"><a href="#t373">373</a></span><span class="t">    <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">validate_on_submit</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t374" class="mis show_mis"><span class="n"><a href="#t374">374</a></span><span class="t">        <span class="nam">student</span> <span class="op">=</span> <span class="nam">Student</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Student</span><span class="op">.</span><span class="nam">student_id</span> <span class="op">==</span> <span class="nam">form</span><span class="op">.</span><span class="nam">student_id</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t375" class="mis show_mis"><span class="n"><a href="#t375">375</a></span><span class="t">        <span class="key">if</span> <span class="nam">student</span> <span class="key">is</span> <span class="key">None</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t376" class="mis show_mis"><span class="n"><a href="#t376">376</a></span><span class="t">            <span class="nam">flash</span><span class="op">(</span><span class="str">'&#26597;&#35810;&#22833;&#36133;&#65281;&#31995;&#32479;&#19981;&#23384;&#22312;&#35813;&#23398;&#29983;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t377" class="mis show_mis"><span class="n"><a href="#t377">377</a></span><span class="t">            <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_lookup_student.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">,</span> <span class="nam">information_list</span><span class="op">=</span><span class="key">None</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t378" class="pln"><span class="n"><a href="#t378">378</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t379" class="pln"><span class="n"><a href="#t379">379</a></span><span class="t">        <span class="com"># &#21015;&#20986;&#20449;&#24687;&#35813;&#25945;&#24072;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t380" class="mis show_mis"><span class="n"><a href="#t380">380</a></span><span class="t">        <span class="nam">information_list</span> <span class="op">=</span> <span class="op">[</span><span class="op">[</span><span class="str">'&#23398;&#21495;'</span><span class="op">,</span> <span class="nam">student</span><span class="op">.</span><span class="nam">student_id</span><span class="op">]</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t381" class="mis show_mis"><span class="n"><a href="#t381">381</a></span><span class="t">        <span class="key">if</span> <span class="nam">student</span><span class="op">.</span><span class="nam">student_name</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span> <span class="key">and</span> <span class="nam">student</span><span class="op">.</span><span class="nam">student_name</span> <span class="op">!=</span> <span class="str">''</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t382" class="mis show_mis"><span class="n"><a href="#t382">382</a></span><span class="t">            <span class="nam">information_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="op">[</span><span class="str">'&#25945;&#24072;&#22995;&#21517;'</span><span class="op">,</span> <span class="nam">student</span><span class="op">.</span><span class="nam">student_name</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t383" class="mis show_mis"><span class="n"><a href="#t383">383</a></span><span class="t">        <span class="key">if</span> <span class="nam">student</span><span class="op">.</span><span class="nam">date_of_birth</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t384" class="mis show_mis"><span class="n"><a href="#t384">384</a></span><span class="t">            <span class="nam">birthday</span> <span class="op">=</span> <span class="nam">student</span><span class="op">.</span><span class="nam">date_of_birth</span>&nbsp;</span><span class="r"></span></p>
    <p id="t385" class="mis show_mis"><span class="n"><a href="#t385">385</a></span><span class="t">            <span class="nam">birthday_str</span> <span class="op">=</span> <span class="nam">str</span><span class="op">(</span><span class="nam">birthday</span><span class="op">.</span><span class="nam">year</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#24180;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">birthday</span><span class="op">.</span><span class="nam">month</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#26376;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">birthday</span><span class="op">.</span><span class="nam">day</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#26085;"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t386" class="mis show_mis"><span class="n"><a href="#t386">386</a></span><span class="t">            <span class="nam">information_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="op">[</span><span class="str">'&#20986;&#29983;&#26085;&#26399;'</span><span class="op">,</span> <span class="nam">birthday_str</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t387" class="mis show_mis"><span class="n"><a href="#t387">387</a></span><span class="t">        <span class="key">if</span> <span class="nam">student</span><span class="op">.</span><span class="nam">graduation_date</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t388" class="mis show_mis"><span class="n"><a href="#t388">388</a></span><span class="t">            <span class="nam">grad_date</span> <span class="op">=</span> <span class="nam">student</span><span class="op">.</span><span class="nam">graduation_date</span>&nbsp;</span><span class="r"></span></p>
    <p id="t389" class="mis show_mis"><span class="n"><a href="#t389">389</a></span><span class="t">            <span class="nam">grad_date_str</span> <span class="op">=</span> <span class="nam">str</span><span class="op">(</span><span class="nam">grad_date</span><span class="op">.</span><span class="nam">year</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#24180;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">grad_date</span><span class="op">.</span><span class="nam">month</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#26376;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">grad_date</span><span class="op">.</span><span class="nam">day</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#26085;"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t390" class="mis show_mis"><span class="n"><a href="#t390">390</a></span><span class="t">            <span class="nam">information_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="op">[</span><span class="str">'&#27605;&#19994;&#26085;&#26399;'</span><span class="op">,</span> <span class="nam">grad_date_str</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t391" class="mis show_mis"><span class="n"><a href="#t391">391</a></span><span class="t">        <span class="key">if</span> <span class="nam">student</span><span class="op">.</span><span class="nam">department</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span> <span class="key">and</span> <span class="nam">student</span><span class="op">.</span><span class="nam">department</span> <span class="op">!=</span> <span class="str">''</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t392" class="mis show_mis"><span class="n"><a href="#t392">392</a></span><span class="t">            <span class="nam">information_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="op">[</span><span class="str">'&#23398;&#38498;'</span><span class="op">,</span> <span class="nam">student</span><span class="op">.</span><span class="nam">department</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t393" class="mis show_mis"><span class="n"><a href="#t393">393</a></span><span class="t">        <span class="key">if</span> <span class="nam">student</span><span class="op">.</span><span class="nam">status</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span> <span class="key">and</span> <span class="nam">student</span><span class="op">.</span><span class="nam">status</span> <span class="op">!=</span> <span class="str">''</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t394" class="mis show_mis"><span class="n"><a href="#t394">394</a></span><span class="t">            <span class="nam">information_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="op">[</span><span class="str">'&#23398;&#21382;'</span><span class="op">,</span> <span class="nam">student</span><span class="op">.</span><span class="nam">status</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t395" class="mis show_mis"><span class="n"><a href="#t395">395</a></span><span class="t">        <span class="key">if</span> <span class="nam">student</span><span class="op">.</span><span class="nam">social_security_number</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span> <span class="key">and</span> <span class="nam">student</span><span class="op">.</span><span class="nam">social_security_number</span> <span class="op">!=</span> <span class="str">''</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t396" class="mis show_mis"><span class="n"><a href="#t396">396</a></span><span class="t">            <span class="nam">information_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="op">[</span><span class="str">'&#36523;&#20221;&#35777;&#21495;&#30721;'</span><span class="op">,</span> <span class="nam">student</span><span class="op">.</span><span class="nam">social_security_number</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t397" class="pln"><span class="n"><a href="#t397">397</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t398" class="mis show_mis"><span class="n"><a href="#t398">398</a></span><span class="t">        <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_lookup_student.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t399" class="pln"><span class="n"><a href="#t399">399</a></span><span class="t">                               <span class="nam">information_list</span><span class="op">=</span><span class="nam">information_list</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t400" class="mis show_mis"><span class="n"><a href="#t400">400</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'registrar/registrar_lookup_student.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">,</span> <span class="nam">information_list</span><span class="op">=</span><span class="key">None</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
</div>
<div id="footer">
    <div class="content">
        <p>
            <a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v5.1</a>,
            created at 2020-06-08 16:42
        </p>
    </div>
</div>
</body>
</html>
